<template>
  <div id="page">
    <div class="top_box">
      <img v-src="'/static/img/my/partnerTop.png'" alt="">
    </div>
    <div class="container">
      <div class="tiaojian">
        <p>
          <span class="title">达成条件:</span>
          <span style="font-size: 0.29rem;color:#424242;">{{pageData.desp}}</span>
        </p>
      </div>
      <div class="renwuliebiao">
        <p>
          <!--<span class="title">任务列表:</span>-->
          <span class="title">任务名称:</span>
          <span class="message">{{pageData.name}}</span>
        </p>
      </div>
    </div>
    <div class="progressBox">
      <h2>进度</h2>
      <div class="progre">
        <v-progress :progress="progress"></v-progress>
      </div>
      <h1>{{progress}}</h1>
    </div>
    <div @click="toApplyParnter" class="btnBox flex-grow-0 flex-y-center flex-x-center" :class="current?'current':''">
      成为合伙人
    </div>
  </div>
</template>
<script>
  import VProgress from 'src/components/common/progress'
  import {GETPROGRESS} from 'src/const/uri'
  export default{
    components:{VProgress},
    data(){
      return {
        message:'',
        current:false,
        progress:'0%',
        pageData:[],
      }
    },
    created(){
    },
    watch:{
      progress(val){
        if(val=='100%'){
          this.current=true;
        }else{
          this.current=false;
        }
      }
    },
    mounted(){
      this.initData();
      let spinner = document.getElementsByClassName('spinner')[0];
      spinner.style.display = 'none';
    },
    methods:{
      initData(){
        this.$ajax.get(GETPROGRESS,{},(res)=>{
          this.pageData=res.data;
          if(res.data.clickCount){
            this.progress=(res.data.clickCount/res.data.allCount)*100+'%';
          }else{
            this.progress='0%'
          }

        })
      },
      refreshData(responseCallback) {
        this.initData();
        responseCallback({code: '0'});
      },
      toApplyParnter(){
        if(this.progress=='100%') {
          let beforeUrl = document.URL.replace(/partner/g, "applyPartner").split('?')[0];
          if (window.WebViewJavascriptBridge) {
            window.WebViewJavascriptBridge.callHandler('jumpTo', beforeUrl);
          } else if (isDebug) {
            window.location.href = beforeUrl;
          }
        }
      }
    }
  }
</script>
<style lang="less" scoped>
  @import "index";
</style>
